﻿Imports System.IO
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports MySql.Data.MySqlClient
Imports System.Data
Imports System.Collections
Public Class frmRptBarcodeList
    Dim Strsql As String
    Dim Mysql As New ClsSQLhelper
    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
        With CrystalReportViewer1
            Strsql = "Select * from item where siteid = " & My.Settings.CurrentSite & " order by itemname "
            print_reports(Strsql, "item")

        End With
    End Sub
    Sub print_reports(ByVal Strsql As String, ByVal Table_Name As String)

        Dim DS_Report As New DSWHIS
        DS_Report = Mysql.GetMYSQLDataset(Strsql, DS_Report, Table_Name)

        If DS_Report.Tables(Table_Name).Rows.Count = 0 Then
            MsgBox("ขออภัยไม่พบข้อมูล", MsgBoxStyle.Information)
            Exit Sub
        End If


        Dim CR As New RptBarcodelists
        CR.SetDataSource(DS_Report)

        'Dim crParameterDiscreteValue As ParameterDiscreteValue
        'Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        'Dim crParameterFieldLocation As ParameterFieldDefinition
        'Dim crParameterValues As ParameterValues


        'crParameterFieldDefinitions = CR.DataDefinition.ParameterFields



        'crParameterFieldLocation = crParameterFieldDefinitions.Item("datestart")
        'crParameterValues = crParameterFieldLocation.CurrentValues
        'crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        'crParameterDiscreteValue.Value = DlgDaterange.DtpFrom.Value.Date

        'crParameterValues.Add(crParameterDiscreteValue)
        'crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

        'crParameterFieldLocation = crParameterFieldDefinitions.Item("dateend")
        'crParameterValues = crParameterFieldLocation.CurrentValues
        'crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        'crParameterDiscreteValue.Value = DlgDaterange.DtpTo.Value.Date

        'crParameterValues.Add(crParameterDiscreteValue)
        'crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

        CrystalReportViewer1.ReportSource = CR



    End Sub
End Class